package bairui.international.weixin.portal.miniapp.controller.pay.order;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_Town;
import bairui.international.service.Service_ProductOrder;
import lombok.Getter;
import lombok.Setter;

/**
 *
 * 线下支付
 *
 * @generated
 * 
 * @see STest_C_Pay_Order_UnderLinePay_Get 测试
 *
 */
@Controller
public class C_Pay_Order_UnderLinePay_Get
 extends SC_Pay_Order_UnderLinePay_Get 
{

	@Autowired private Service_ProductOrder service_ProductOrder;
	
	/**
	 * Get请求
	 */
	@Action(Get.class)
	@PostMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request, 
		@PathVariable(name=Get.PathVariableName.OrderId) long orderId,
		@RequestBody Input input,
		@RequestParam(required=false) Long ticketId
	) throws Exception {
		InputAddress address = input.getAddress();
		service_ProductOrder.payUnderLine(input.getScore(), orderId, ticketId, new TB_Town(address.getTownId()), address.getUsername(), address.getPhone(), address.getDetailAddress(), input.getComment());
		return null;
	}
	
	public static class Input {
		@Getter @Setter private Double score;
		@Getter @Setter private String comment;
		@Getter @Setter private InputAddress address;
	}
	
	public static class InputAddress {
		@Getter @Setter Long townId;
		@Getter @Setter private Boolean defaultFlag;
		@Getter @Setter private String detailAddress;
		@Getter @Setter private String username;
		@Getter @Setter private String phone;
	}
	
}
